import 'package:flutter/material.dart';
import 'package:x3_charts_core/chart_painter/round_water_drop_chart_painter.dart';
import 'package:x3_charts_core/model/round_water_drop_chart_model.dart';

///**
///* @author hrongyong
///* @date   2/4/21
///* @email hrongyong@gmail.com
///* Description:
///*/
class RoundWaterDropChartWidget extends StatelessWidget {
  final RoundWaterDropChartModel chartModel;

  ///上标
  final Color superscriptColor;

  ///中间
  final Color middleColor;

  ///下标
  final Color subscriptColor;

  ///主题颜色
  final Color themeColor;

  ///上中下标大小
  final double fontSize;

  RoundWaterDropChartWidget({
    @required this.chartModel,
    @required this.themeColor,
    this.superscriptColor = const Color(0xFFC64545),
    this.middleColor = Colors.white,
    this.subscriptColor = const Color(0xFF000000),
    this.fontSize = 4,
  });

  @override
  Widget build(BuildContext context) {
    return Container(
      child: LayoutBuilder(
        builder: (BuildContext context, BoxConstraints constraints) {
          return CustomPaint(
            size: Size(constraints.maxWidth, constraints.maxHeight),
            painter: RoundWaterDropChartPainter(
              themeColor: this.themeColor,
              superscript: chartModel.superscript,
              superscriptColor: this.superscriptColor,
              middle: chartModel.middle,
              middleColor: this.middleColor,
              subscript: chartModel.subscript,
              subscriptColor: this.subscriptColor,
              fontSize: fontSize,
            ),
          );
        },
      ),
    );
  }
}
